package org.wk.common.jpush.vo;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

/**
 * @author df.wu
 * @version V1.0
 * @title: CustomAudience
 * @package com.athena.base.service.vo
 * @Date 10:03 2017/11/24
 * @description:
 */
public class CustomAudience {
    private boolean all;
    private Set<CustomAudienceTarget> targets;

    private CustomAudience(){}

    public CustomAudience(Set<CustomAudienceTarget> targets) {
        this.all = false;
        this.targets = targets;
    }

    private CustomAudience(boolean all, Set<CustomAudienceTarget> targets) {
        this.all = all;
        this.targets = targets;
    }

    public static CustomAudience all() {
        return new CustomAudience().setAll(true);
    }

    public static CustomAudience tag(String... tagValue) {
        CustomAudienceTarget target = CustomAudienceTarget.tag(tagValue);
        return new CustomAudience().addAudienceTarget(target);
    }



    public static CustomAudience tag(Collection<String> tagValues) {
        CustomAudienceTarget target = CustomAudienceTarget.tag(tagValues);
        return new CustomAudience().addAudienceTarget(target);
    }

    public static CustomAudience tag_and(String... tagValue) {
        CustomAudienceTarget target = CustomAudienceTarget.tag_and(tagValue);
        return new CustomAudience().addAudienceTarget(target);
    }

    public static CustomAudience tag_and(Collection<String> tagValues) {
        CustomAudienceTarget target = CustomAudienceTarget.tag_and(tagValues);
        return new CustomAudience().addAudienceTarget(target);
    }

    public static CustomAudience tag_not(String... tagValue) {
        CustomAudienceTarget target = CustomAudienceTarget.tag_not(tagValue);
        return new CustomAudience().addAudienceTarget(target);
    }

    public static CustomAudience tag_not(Collection<String> tagValues) {
        CustomAudienceTarget target = CustomAudienceTarget.tag_not(tagValues);
        return new CustomAudience().addAudienceTarget(target);
    }

    public static CustomAudience alias(String... alias) {
        CustomAudienceTarget target = CustomAudienceTarget.alias(alias);
        return new CustomAudience().addAudienceTarget(target);
    }

    public static CustomAudience alias(Collection<String> aliases) {
        CustomAudienceTarget target = CustomAudienceTarget.alias(aliases);
        return new CustomAudience().addAudienceTarget(target);
    }

    public static CustomAudience segment(String... segment) {
        CustomAudienceTarget target = CustomAudienceTarget.segment(segment);
        return new CustomAudience().addAudienceTarget(target);
    }

    public static CustomAudience segment(Collection<String> segments) {
        CustomAudienceTarget target = CustomAudienceTarget.segment(segments);
        return new CustomAudience().addAudienceTarget(target);
    }

    public static CustomAudience registrationId(String... registrationId) {
        CustomAudienceTarget target = CustomAudienceTarget.registrationId(registrationId);
        return new CustomAudience().addAudienceTarget(target);
    }

    public static CustomAudience registrationId(Collection<String> registrationIds) {
        CustomAudienceTarget target = CustomAudienceTarget.registrationId(registrationIds);
        return new CustomAudience().addAudienceTarget(target);
    }

    public static CustomAudience abTest(String... abTestId) {
        CustomAudienceTarget target = CustomAudienceTarget.abTest(abTestId);
        return new CustomAudience().addAudienceTarget(target);
    }

    public static CustomAudience abTest(Collection<String> abTestIds) {
        CustomAudienceTarget target = CustomAudienceTarget.abTest(abTestIds);
        return new CustomAudience().addAudienceTarget(target);
    }

    public boolean isAll() {
        return this.all;
    }

    public CustomAudience setAll(boolean all) {
        this.all = all;
        return this;
    }
    private CustomAudience addAudienceTarget(CustomAudienceTarget target) {
        if (null == this.targets) {
            this.targets = new HashSet();
        }
        this.targets.add(target);
        return this;
    }

    public Set<CustomAudienceTarget> getTargets() {
        return targets;
    }

    public void setTargets(Set<CustomAudienceTarget> targets) {
        this.targets = targets;
    }


}
